--- %%NOBANNER%% -->
/*-------------------<-- Start of Description -->--------------------\
| Convert a directory of SAS V6 datasets, views and catalogs to V8; |
|---------------------<-- End of Description -->---------------------|
|--------------------------------------------------------------------|
|-----------<-- Start of Files or Arguements Needed-->---------------|
| Arguments: |
| directory - the directory of V6 datasets; |
| memtype - the type of SAS files you want to convert; |
|------------<-- End of Files or Arguements Needed-->----------------|
|--------------------------------------------------------------------|
|------------------<-- Start of Files Created-->---------------------|
| Example: %lv6tov8("D:\Software Temp\SAS Temporary Files"); |
| Usage: %lv6tov8(directory, memtype=DATA VIEW CATALOG); |
\------------------<-- Start of Files Created-->--------------------*/
%macro lv6tov8(directory, memtype=DATA VIEW CATALOG);
/*--------------------------------------------\
| Author: Duo Zhou; |
| Created: 11-28-2001 9:56pm; |
| Purpose: Convert a directory of SAS V6 data |
| sets to V8 data sets; |
\--------------------------------------------*/
%local onotes ov6path ov8path ntype mtype tmptype _tmplast_;
%let _tmplast_=&syslast;
%let directory=%sysfunc(dequote(&directory));
%let memtype=%sysfunc(dequote(&memtype));
%let mtype=%upcase(%trim(%left(&memtype)));
%let ntype=%words(&mtype);
%let memtype=;
%do _i_=1 %to &ntype;
%let tmptype=%qscan(&mtype,&_i_,%str( ));
%if %quote(&tmptype)=%quote(DATA) or
%quote(&tmptype)=%quote(VIEW) or
%quote(&tmptype)=%quote(CATALOG) %then %do;
%let memtype= %trim(%left(&memtype)) &tmptype;
%end;
%else %do;
%put ==> Alert! I can%str(%')t recognize "&tmptype", I can take only "DATA", "VIEW" and "CATALOG".;
%end;
%end;
%if &directory ^= %then %do;
%let ov6path=%sysfunc(pathname(testv6));
LIBNAME TestV6 v6 "&directory";
%let ov8path=%sysfunc(pathname(testv8));
LIBNAME TestV8 "&directory";
proc copy in=testv6 out=testv8 memtype=(&memtype) index=yes clone;
run;
%if (not %index(%quote(&memtype), %str(CATALOG))) %then %do;
proc cport lib=TestV6 file='CV6toV8.xpt' memtype=CATALOG;
run;
proc cimport lib=TestV8 infile='CV6toV8.xpt';
run;
%end;
%if "&ov6path" = "" %then %do; libname TestV6 clear; %end;
%else %do; libname TestV6 "&ov6path"; %end;
%if "&ov8path" = "" %then %do; libname TestV8 clear; %end;
%else %do; libname TestV8 "&ov8path"; %end;
%end;
%else %do;
%let onotes=%sysfunc(getoption(notes, keyword));
options nonotes;
data _null_;
length x $80;
put;
put ' Macro, LV6toV8, converts a Version 6 library to Version 8. ';
put ' It copies all members to the same physical directory, but with ';
put ' the Version 8 engine and file extensions. The call is as follows: ';
put;
x = ' %' || 'LibV6toV8(directory, memtype=data view catalog);';
put x $char.;
put;
put ' NOTE: The engine you specify for a subsequent libref will show only ';
put ' members created by that engine. If you wish to return the V6 ';
put ' space to the operating system, you will need to delete the V6 ';
put ' members via PROC DATASETS or with an OS command. Uses libnames';
put ' TestV6 and TestV8. Attampts to restore using default engine. ';
put;
put ' If you specify the parameter "catalog", LV6toV8 uses PROC COPY ';
put ' rather than PROC CPORT/CIMPORT to convert SAS catalog members. ';
put ' "catalog" is the only valid value for this paramter. If any ';
put ' other value appears, including blan (omitted), the PROC CPORT/ ';
put ' CIMPORT combination is used. Use this parameter to convert/ ';
put ' SASUSER libraries which contain WINLIB, WSAVE, and WINPRINT ';
put ' entries which CPORT will not transport and PROC COPY will. ';
put;
run;
options &onotes;
%end;
%let syslast=&_tmplast_;
%mend lv6tov8;